<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>

<html>
<head>
    <title>登录页</title>
    <%--echart线图、柱状图、饼图等各种图型库 cdn--%>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
    <%--jquery cdn--%>
    <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>
</head>
<body>


<form action="/list.do">
    姓名/工号 <input name="nameOrNum" value="${query.nameOrNum}"> <br>
    部门 <select name="deptId">
        <option value="">请选择</option>
        <c:forEach items="${deptList}" var="d">
            <option    ${query.deptId == d.id ? 'selected':''}         value="${d.id}">${d.name}</option>
        </c:forEach>
        </select> <br>
    小组 <select name="groupId">
    <option value="">请选择</option>
    <c:forEach items="${groupList}" var="g">
        <option    ${query.groupId == g.id ? 'selected':''}         value="${g.id}">${g.name}</option>
    </c:forEach>
</select> <br>
    是否考勤 <select name="kaoqin">
    <option value="">请选择</option>
    <option  ${query.kaoqin == 1 ? 'selected':''}    value="1">是</option>
    <option ${query.kaoqin == 0 ? 'selected':''} value="0">否</option>

</select> <br>

    入职日期
    <input type="date" name="startTime" value="${query.startTime}">
    <input type="date" name="endTime" value="${query.endTime}">
<br>
<input type="submit" value="查询">
<input type="button" value="批量删除" onclick="batchDel()">
    <a href="/addPage.do">添加</a>

    <table>
        <tr>
            <td>操作</td>
            <td>id</td>
            <td>工号</td>
            <td>姓名</td>
            <td>性别</td>
            <td>出生日期</td>
            <td>部门</td>
            <td>分组</td>
            <td>是否考勤</td>
            <td>入职日期</td>
            <td>状态</td>
            <td>操作</td>
        </tr>

        <c:forEach items="${pageInfo.list}" var="e">
            <tr>
                <td> <input type="checkbox" name="eId" value="${e.id}"></td>
                <td>${e.id}</td>
                <td>${e.num}</td>
                <td>${e.name}</td>
                <td>${e.sex == 1 ? '男':'女'}</td>
                <td>${e.birthDay}</td>
                <td>${e.deptName}</td>
                <td>${e.groupName}</td>
                <td>${e.kaoqin == 1 ? '是':'否'}</td>
                <td>${e.createTime}</td>
                <td>${e.status}</td>
                <td> <a href="/del.do?id=${e.id}">删除</a></td>
            </tr>

        </c:forEach>

        <tr>
            <td> <button name="pageNum"  value="1">首页</button></td>
            <td> <button name="pageNum"  value="${pageInfo.prePage}">上页</button></td>
            <td> <button name="pageNum"  value="${pageInfo.nextPage}">下页</button></td>
            <td> <button name="pageNum"  value="${pageInfo.pages}">尾页</button></td>
        </tr>
    </table>



</form>


</body>
<script>

    function batchDel() {

        var ids = [];
        $('[name=eId]:checked').each(function (){
            let id = this.value;
            console.log(id)
            ids.push(id);
        })

        if (ids.length == 0){
            alert("请至少选择一条数据删除")
            return;
        }

        window.location.href = '/del.do?id=' + ids
    }
</script>
</html>